package com.xusheng.cli.service.impl;

import com.xusheng.cli.common.base.MyServiceImpl;
import com.xusheng.cli.entity.proxyHostModule.ProxyHost;
import com.xusheng.cli.entity.proxyHostModule.ProxyHostVO;
import com.xusheng.cli.mapper.ProxyHostMapper;
import com.xusheng.cli.service.ProxyHostService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 代理--域名(ProxyHost)表服务实现类
 *
 * @author whr
 * @since 2024-03-20 14:01:55
 */
@Service("proxyHostService")
public class ProxyHostServiceImpl extends MyServiceImpl<ProxyHostMapper, ProxyHost> implements ProxyHostService {

    /**
     * @param proxyHostVO
     * @return
     */
    @Override
    public boolean setHosts(ProxyHostVO proxyHostVO) {
        // 字符替换，换,
        String hostsStr = proxyHostVO.getHosts().replace("，", ",");
        String[] split = hostsStr.split(",");
        for (String s : split) {
            ProxyHost proxyHost = new ProxyHost();
            proxyHost.setAllocation(false);
            proxyHost.setProxyId(proxyHostVO.getProxyId());
            proxyHost.setHost(s);
            baseMapper.insert(proxyHost);
        }
        return true;
    }

    /**
     * @param proxyHost
     * @return
     */
    @Override
    public List<ProxyHost> selectOptionsTwo(ProxyHost proxyHost) {
        return baseMapper.selectOptionsTwo(proxyHost);
    }

    /**
     * @param proxyHost
     * @return
     */
    @Override
    public List<ProxyHost> selectOptionsThree(ProxyHost proxyHost) {
        return baseMapper.selectOptionsThree(proxyHost);
    }
}

